# -*- coding: utf-8 -*-
"""
Created on Wed Sep 27 11:07:21 2017

@author: mzheng50
"""

import argparse
import matplotlib.pyplot as plot
import chainer
from chainercv.datasets import camvid_label_colors
from chainercv.datasets import camvid_label_names
from chainercv.links import SegNetBasic
from chainercv import utils
from chainercv.visualizations import vis_image
from chainercv.visualizations.vis_semantic_segmentation import vis_semantic_segmentation


# pre-model + read picture
img = utils.read_image('../../46.jpg', color=True)
model = SegNetBasic(n_class = 11,pretrained_model  = 'camvid')
labels = model.predict([img])

# plot
label = labels[0]  # (332, 500)
fig = plot.figure()
ax1 = fig.add_subplot(1, 2, 1)
vis_image(img, ax=ax1)
ax2 = fig.add_subplot(1, 2, 2)
vis_semantic_segmentation(label, camvid_label_names, camvid_label_colors, ax=ax2)
plot.show()

